// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.Styles;

import java.io.Serializable;

public class FloatList implements Serializable {
    private static final long serialVersionUID = 1L;
    private float[] value;
    private int count = 0;
    private final boolean fastExpand;

    public FloatList() {
        this(0);
    }

    public FloatList(int size) {
        this(true, size);
    }

    public FloatList(boolean _fastExpand, int size) {
        this.fastExpand = _fastExpand;
        this.value = new float[size];
    }

    public float add(float f) {
        if (this.count == this.value.length) {
            float[] _float = this.value;
            if (this.fastExpand) {
                this.value = new float[(_float.length << 1) + 1];
            } else {
                this.value = new float[_float.length + 1];
            }

            System.arraycopy(_float, 0, this.value, 0, _float.length);
        }

        this.value[this.count] = f;
        return (float)(this.count++);
    }

    public float remove(int idx) {
        if (idx < this.count && idx >= 0) {
            float _float = this.value[idx];
            if (idx < this.count - 1) {
                System.arraycopy(this.value, idx + 1, this.value, idx, this.count - idx - 1);
            }

            this.count--;
            return _float;
        } else {
            throw new IndexOutOfBoundsException("Referenced " + idx + ", size=" + this.count);
        }
    }

    public void addAll(float[] _float) {
        this.ensureCapacity(this.count + _float.length);
        System.arraycopy(_float, 0, this.value, this.count, _float.length);
        this.count += _float.length;
    }

    public void addAll(FloatList f) {
        this.ensureCapacity(this.count + f.count);
        System.arraycopy(f.value, 0, this.value, this.count, f.count);
        this.count = this.count + f.count;
    }

    public float[] array() {
        return this.value;
    }

    public int capacity() {
        return this.value.length;
    }

    public void clear() {
        this.count = 0;
    }

    public void ensureCapacity(int size) {
        if (this.value.length < size) {
            float[] _float = this.value;
            this.value = new float[size];
            System.arraycopy(_float, 0, this.value, 0, _float.length);
        }
    }

    public float get(int index) {
        return this.value[index];
    }

    public boolean isEmpty() {
        return this.count == 0;
    }

    public int size() {
        return this.count;
    }

    public void toArray(Object[] object) {
        System.arraycopy(this.value, 0, object, 0, this.count);
    }

    public void trimToSize() {
        if (this.count != this.value.length) {
            float[] _float = this.value;
            this.value = new float[this.count];
            System.arraycopy(_float, 0, this.value, 0, this.count);
        }
    }
}
